<template>
	<view class="container">
		<view class="layout">
			<view class="list-box">
				<view class="top">
					<view class="text">
						<text class="label">广告收益(元)</text>
						<uni-icons type="help" size="16" color="#717186"></uni-icons>
					</view>
					<view class="money">{{ state.money }}</view>
				</view>
				<view class="footer">
					<view class="textBtn" @click="lookDetail(1)">查明细</view>
					<view class="textBtn" @click="goTixian(1, state.money)">去提现</view>
				</view>
			</view>
			<view class="list-box">
				<view class="top">
					<view class="text">激活奖励(元)</view>
					<view class="money">{{ state.money2 }}</view>
				</view>
				<view class="footer">
					<view class="textBtn" @click="lookDetail(2)">查明细</view>
					<view class="textBtn" @click="goTixian(3, state.money2)">去提现</view>
				</view>
			</view>
		</view>
		<uni-popup type="center" ref="popup">
			<view class="popup-container">
				<view class="popup-title">每日10号后可提现1次</view>
				<view class="btn-center">
					<view class="btn confirm" @click="cancel">我知道了</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue';
import { dayjs } from '@/static/dayjs.min.js';
import { onShow, onReachBottom } from '@dcloudio/uni-app';

onShow(() => {
	const str = uni.getStorageSync('userinfo');
	const userInfo = JSON.parse(str);
	state.money = userInfo.money_gao;
	state.money2 = userInfo.money_ji;
});

const state = reactive({
	money: 0,
	money2: 0
});

const popup = ref();
const goTixian = (p, n) => {
	const day = dayjs().format('D');
	if (day >= 10) {
		uni.navigateTo({
			url: `/pages/tixiandetail/tixiandetail?money=${n}&type=${p}`
		});
	} else {
		popup.value.open();
	}
};
const lookDetail = (n) => {
	let path = '';
	if (n == 1) {
		path = '/pages/guanggaoshouyi/guanggaoshouyi';
	} else if (n == 2) {
		path = '/pages/jihuoshouyi/jihuoshouyi';
	}
	uni.navigateTo({
		url: path
	});
};
</script>
